/**
 * 
 */
package cn.softTank.BpelModelImpl;

import java.util.ArrayList;
import java.util.List;

import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import cn.softTank.BpelModel.ToPart;
import cn.softTank.BpelModel.ToParts;

/**
 * @author Yuzone (smartzxy@gmail.com)
 * 
 */
public class ToPartsImpl implements ToParts {

	private List<ToPart> toPart;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.softTank.BpelModel.ToParts#addToPart(cn.softTank.BpelModel.ToPart)
	 */
	@Override
	public void addToPart(ToPart value) {
		if (toPart == null)
			toPart = new ArrayList<ToPart>();
		toPart.add(value);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.ToParts#getToPart()
	 */
	@Override
	public List<ToPart> getToPart() {
		return toPart;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.ToParts#removeToPartAt(int)
	 */
	@Override
	public void removeToPartAt(int index) {
		if (toPart != null && index < toPart.size())
			toPart.remove(index);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.ToParts#setToPart(java.util.List)
	 */
	@Override
	public void setToPart(List<ToPart> value) {
		toPart = value;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toElement()
	 */
	@Override
	public Element toElement() {
		Element e = DocumentHelper.createElement("toParts");
		if (toPart != null)
			for (int i = 0; i < toPart.size(); i++)
				e.add(toPart.get(i).toElement());
		return e;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see cn.softTank.BpelModel.XmlAdapt#toXml()
	 */
	@Override
	public String toXml() {
		// TODO Auto-generated method stub
		return null;
	}

}
